<?php

	global $database;
	
	$homePage = $database->select("SELECT * FROM config WHERE id =". ARID ." ");
	$exito = 0;
	
	if(isset($_GET['funcion']) && $_GET['funcion'] == 'guardar'){
		
		$vars = array();
		
		$vars['home'] = $_POST['content'];
		$database->update_array('config', $vars, "id=". ARID ."");
		
		$exito = 1;
	}

?>



<script type="text/javascript" src="js/tinyMce/tiny_mce.js"></script>
<script type="text/javascript">
	tinyMCE.init({
		// General options
		language : "es", 
      mode : "textareas",
      theme : "advanced",
      plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

      // Theme options
      theme_advanced_buttons1 : "template, preview",
      theme_advanced_buttons2 : "newdocument, save,|,undo, redo,|,cut, copy, paste, pastetext, pasteword,|,search,replace,|,styleselect,formatselect,fontselect,fontsizeselect",
      theme_advanced_buttons3 : "bold,italic,underline,strikethroughcut,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,outdent,indent,blockquote,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,|,forecolor,backcolor",
      theme_advanced_buttons4 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
      theme_advanced_buttons5 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,blockquote,pagebreak,|,insertfile,insertimage",
      theme_advanced_toolbar_location : "top",
      theme_advanced_toolbar_align : "left",
      theme_advanced_statusbar_location : "bottom",
      theme_advanced_resizing : false,

      // Skin options
      skin : "o2k7",
      skin_variant : "silver",

      // Example content CSS (should be your site CSS)
      content_css : "css/example.css",

      // Drop lists for link/image/media/template dialogs
      template_external_list_url : "js/tiniMce/plugins/template/jstemplate_list.js",
      external_link_list_url : "js/link_list.js",
      external_image_list_url : "js/image_list.js",
      media_external_list_url : "js/media_list.js",

      // Replace values for the template plugin
      template_replace_values : {
      	username : "Some User",
      	staffid : "991234"
      }
});
</script>

<div class="tituloOpcionesAdmin">
	<img src="images/icons/page_edit.png"/>
	Página Principal
</div>

<?php
	if($exito == 1){
		echo '
		<div class="productoAgregado">
			<img src="accept.png" border="0">
			La página principal ha sido guardada con éxito.
		</div>
		';
	}
	
	$homePage = $database->select("SELECT * FROM config WHERE id =". ARID ." ");
?>
			
<div class="descripcionOpcionesAdmin">
	Herramienta dinámica que permite que usted diseñe su propia página principal
	<br />
	Hemos cargado para su ayuda algunos diseños que pueden ser modificados a gusto.
</div>

<div class="instruccionesConfigPage">
El primer botón permite seleccionar algún diseño pre-establecido y trabajar sobre él.
<br />
El segundo botón muestra una vista previa. Cuando este conforme guarde.
</div>

<form method="POST" action="index.php?edit=home&amp;funcion=guardar">
	<div class="contenidoConfigPagPrincipal">
		<textarea name="content" ><?php echo $homePage[0]['home']; ?></textarea>
	</div>

	<div class="botonConfigMain">
		<input type="submit" value="Guardar">
	</div>
</form>
